package 随机点名多方面介绍;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class 随机点名 {
    public static void main(String[] args) {
        /*
        班级有N个学生，学生属性：姓名，年龄，性别
        实现随机点名
         */
        //定义集合
        ArrayList<String> list=new ArrayList<>();
        //添加名字
        Collections.addAll(list,"马超","张飞","刘备","关羽","蔡文姬","张机","曹操","孙权","妲己","甄洛");
        //开始随机点名
        Random r=new Random();
        int index=r.nextInt(list.size());
        //利用索引获取对应名字
        String name=list.get(index);
        //打印随机到的名字
        System.out.println(name);

    }
}
